package hotel.controller;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import hotel.pojo.GuestDto;
import hotel.service.GuestConditionService;

@Controller
public class GuestConditionCotroller {
	@Resource
	GuestConditionService guestCoditionService;
	
	@RequestMapping(produces="application/json;charset=UTF-8",
			value="guestCondition",method= {RequestMethod.POST})
	@ResponseBody
	public Map<String,Object> guestCondition(HttpServletRequest request,HttpServletResponse response,String message,String status){
		Map<String,Object> map = new HashMap<String,Object>();
		List<GuestDto> list = guestCoditionService.GuestMessageService(message, status);
		if(list == null) {
			map.put("error", "is empty");
		}
		map.put("message", "susseed to find");
		map.put("info", list);
		return map;
	}
	
	@RequestMapping(produces="application/json;charset=UTF-8",
			value="checkInGuest",method= {RequestMethod.POST})
	@ResponseBody
	public Map<String,Object> checkInGuest(HttpServletRequest request,HttpServletResponse response,String room,String name,String sex,String age,String tel,String id,String time,String mony){
		Map<String,Object> map = new HashMap<String,Object>();
		System.out.println("room = "+room);
		boolean judge = guestCoditionService.checkInService(room, name, sex, age, tel, id, time, mony);
		if(judge) {
			map.put("message","susseed to inset");
			return map;
		}
		map.put("error", "fial to inset");
		return map;
	}
	
}
